#include <iostream>
#include <string>

using namespace std;

class Solution
{
public:
    int lengthOfLastWord(string s)
    {
        int count = -1;
        for (int i = s.size() - 1; i >= 0; i--)
        {
            if (s[i] == ' ')
            {
                if (count != -1)
                    return count;
            }
            else
            {
                if (count == -1)
                    count = 1;
                else
                    count += 1;
            }
        }
        return count;
    }
};

int main()
{
    cout << "Code58" << endl;
    Solution s;
    string ss = "  monn";
    cout << s.lengthOfLastWord(ss);
    return 0;
}